//
// Created by 17775 on 2024/9/26.
//

#ifndef RAYCI_LIVEMODE_CROSSSECTION_H
#define RAYCI_LIVEMODE_CROSSSECTION_H


#include <QObject>
#include <thread>
#include "RayCiPro_C.h"
#include "../utils/CrossSectionDataReceiveQueueObserver.h"
#include <QDebug>

class LiveMode_CrossSection: public QObject {
Q_OBJECT

signals:
    void rescaleCurve();

public:
    explicit LiveMode_CrossSection(int &docId);
    ~LiveMode_CrossSection() override;
    std::thread m_crossSectionThread;
    std::atomic<bool> _isGettingNewCrossSectionData = false;
    std::atomic<bool> _isGettingYCrossSectionData = false;
    void addPowerProfileDataListener(CrossSectionDataReceiveListener *listener) const;

    void getCrossData();
    void getCrossSectionData();
    void stopCrossSectionThread();
    void closeCrossSectionWindow() const;

    void setAdjustmentActive(bool bActive) const;
    void setAdjustmentMethod(int nMethods) const;
    void setLimitEnable(bool bEnable);

    void setX_px(int nY) const;
    void setY_px(int nX) const;
    void setRadial_px(double dX, double dY, double dAngle) const;
    void setArbitrary_px(double dX1, double dY1, double dX2, double dY2) const;
    void setCircle_px(double dX, double dY, double dR) const;

private:
    int _nDocIdLive = 0;
    int _nIdCS = 0;
    int iCount = 0;
    bool _bCrossSectionValid = false;
    bool _bLimitEnable = false;
    bool _bActive = false;
    int iDataLength = 0;
    int preDataLength = 0;
    CrossSectionDataReceiveQueueObserver *crossSectionDataReceiveQueueObserver = nullptr;
};


#endif //RAYCI_LIVEMODE_CROSSSECTION_H
